package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.BillType;
import com.cloudfun.campusshare.common.constant.ServiceType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2020/4/17 9:33
 * @description :
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "bill")
public class BillEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", nullable = false, unique = true, length = 40)
    private String id;

    @Column(columnDefinition = ("varchar(40) not null comment '用户id'"))
    private String userId;

    @Column(columnDefinition = ("varchar(40) not null comment '订单id'"))
    private String orderId;

    @Column(columnDefinition = ("varchar(32) not null comment '服务类型'"))
    @Enumerated(EnumType.STRING)
    private ServiceType serviceType;

    @Column(columnDefinition = ("varchar(32) not null comment '账单类型'"))
    @Enumerated(EnumType.STRING)
    private BillType billType;

    @Column(columnDefinition = ("int(11) not null comment '金额'"))
    private Integer amount;

    @Column(columnDefinition = ("timestamp(6) not null comment '账单时间'"))
    private LocalDateTime createTime;
}
